package com.kingyun.gpsinspection.purificationservice.services.activitiservice.ext.personrule;

import com.google.common.base.Strings;
import com.kingyun.gpsinspection.purificationservice.facade.model.activiti.BpmConfNode;
import com.kingyun.gpsinspection.purificationservice.services.activitiservice.ext.exception.AssignException;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;

/**
 * 单个人员配置规则
 * @author zjh
 * @since 20170615
 */
public class PersonRule implements Rule {

    private static PersonRule personRule;

    private PersonRule(){}

    public static PersonRule getInstance(){
        if(personRule==null){
            personRule=new PersonRule();
        }
        return personRule;
    }

    @Override
    public void assigneRule(ActivityExecution execution,TaskEntity task, BpmConfNode bpmConfUser) {
        if(Strings.isNullOrEmpty(bpmConfUser.getUserValue())){
            throw new AssignException("没有相关用户");
        }
        task.setAssignee(bpmConfUser.getUserValue());
    }
}
